package com.lvyq.javaprint.view.index;

import com.lvyq.javaprint.constant.ImgConstant;
import com.lvyq.javaprint.constant.TrayConstant;
import com.lvyq.javaprint.view.style.STYLE;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import java.net.URI;


/**
 * @author lvyq 代理设置
 * @version 1.0
 * Create by 2025-01-06 17:11
 */
public class OpinionView {

    static BorderPane opinionView = new BorderPane();


    /**
     * @description 创建代理设置内容
     * @author lvyq
     * @throws
     * @return VBox
     * @time 2025-08-15 12:33
     */
    public static BorderPane createOpinionBoxView( ) {
        //界面最外层
        opinionView.setPrefWidth(TrayConstant.stageW-TrayConstant.pane_Hor_Margin*2-3.50);
        opinionView.setPrefHeight(TrayConstant.stageH-TrayConstant.pane_Vet_Margin*2-28.00);
        opinionView.setStyle("-fx-background-color: rgba(0.0,0.0,0.0,0.0);-fx-border-color: rgba(0.0,0.0,0.0,0.2);" +
                "-fx-border-width: 2;-fx-border-radius: 4");

        VBox topBox = new VBox();
        topBox.setAlignment(Pos.CENTER);
        Label label = new Label("请优先Gitee反馈问题或者建议！加群请备注【打印】");
        topBox.getChildren().addAll(label);
        opinionView.setTop(topBox);


        VBox leftBox = new VBox(10);
        leftBox.setPrefHeight(95.00);
        //宽度小于scrollPane宽度，避免出现水平滑动框
        leftBox.setStyle("-fx-background-color: rgba(0.0,0.0,0.0,0.0);  -fx-background-insets: 0;");

        Button giteeBut = new Button("前往Gitee");
        giteeBut.setGraphic(new ImageView(new Image(ImgConstant.OPINION_GITEE)));
        Button qqGroupBut = new Button("加入群聊");
        qqGroupBut.setGraphic(new ImageView(new Image(ImgConstant.OPINION_QQ_GROUP)));
        Button weChatBut = new Button("添加好友");
        weChatBut.setGraphic(new ImageView(new Image(ImgConstant.OPINION_WECHAT)));
        STYLE.BUTTON.tertiary_style(giteeBut);
        STYLE.BUTTON.tertiary_style(qqGroupBut);
        STYLE.BUTTON.tertiary_style(weChatBut);
        leftBox.getChildren().addAll(giteeBut,qqGroupBut,weChatBut);

        opinionView.setLeft(leftBox);


        ScrollPane centerView = new ScrollPane();

        VBox gitteBox = new VBox();
        gitteBox.setAlignment(Pos.CENTER);
        Label giteeUrl = new Label("前往获取解决方案");
        giteeUrl.setStyle("-fx-text-fill: CADETBLUE; -fx-underline: true;  ");
        giteeUrl.setCursor(Cursor.HAND);
        giteeUrl.setOnMouseClicked(e -> {
            try {
                java.awt.Desktop.getDesktop().browse(
                        new URI("https://gitee.com/BuYaoPenXiangShui/java-print/issues?q=is%3Aall")
                );
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        });
        gitteBox.getChildren().addAll(giteeUrl);


        centerView.setContent(gitteBox);

        giteeBut.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                centerView.setContent(gitteBox);
            }
        });
        giteeBut.isFocused();
        weChatBut.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {

                ImageView imageView = new ImageView(new Image(ImgConstant.AUTHOR_WECHAT));
                imageView.setFitWidth(150);
                imageView.setFitHeight(150);
                centerView.setContent(imageView);
            }
        });


        qqGroupBut.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {

                ImageView imageView = new ImageView(new Image(ImgConstant.AUTHOR_QQ));
                imageView.setFitWidth(150);
                imageView.setFitHeight(150);
                centerView.setContent(imageView);
            }
        });
        opinionView.setCenter(centerView);


        return opinionView;
    }


}





